package com.example.controller;

import com.example.domain.Annualoutput;
import com.example.domain.Result;
import com.example.service.AnnualoutputService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/output")
public class AnnualoutputController {

    @Autowired
    private AnnualoutputService annualoutputService;

    @GetMapping
    public Result getAll(){
        return new Result(true,annualoutputService.getAll());
    }

    @GetMapping("{annualoutputId}")
    public Result getById(@PathVariable Integer annualoutputId){
        return new Result(true,annualoutputService.getById(annualoutputId));
    }

    @PostMapping
    public Result add(@RequestBody Annualoutput annualoutput) {
        boolean code = annualoutputService.add(annualoutput);
        return new Result(code);
    }

    @PutMapping
    public Result update(@RequestBody Annualoutput annualoutput){
        boolean code = annualoutputService.update(annualoutput);
        return new Result(code);
    }

    @DeleteMapping("{annualoutputId}")
    public Result delete(@PathVariable Integer annualoutputId){
        boolean code = annualoutputService.delete(annualoutputId);
        return new Result(code);
    }

}
